]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
NetworkMenu: make sure menu icons are updated at the end of connectivity checks
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 15 Mar 2014 11:40:13 +0000 (12:40 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Thu, 26 Jun 2014 17:23:57 +0000 (19:23 +0200)
Icons inside the menu are updated only for device state change,
but for the main device they also depend on connectivity (which
is a global property).
Add a public method to force an update of the icon, and call it
when connectivity changes.

https://bugzilla.gnome.org/show_bug.cgi?id=726401

js/ui/status/network.js

index 7d68fbd5379e684f53d1e39e8a625a5ffdf878cd..f3e568dd644ae6e2fccf7b7fac0769d5a71a256e 100644 (file)
@@ -207,13 +207,23 @@ const NMConnectionSection = new Lang.Class({
         this.item.menu.addMenuItem(this._labelSection);
         this.item.menu.addMenuItem(this._radioSection);
 
-        this.connect('icon-changed', Lang.bind(this, this._sync));
+        this._notifyConnectivityId = this._client.connect('notify::connectivity', Lang.bind(this, this._iconChanged));
     },
 
     destroy: function() {
+        if (this._notifyConnectivityId != 0) {
+            this._client.disconnect(this._notifyConnectivityId);
+            this._notifyConnectivityId = 0;
+        }
+
         this.item.destroy();
     },
 
+    _iconChanged: function() {
+        this._sync();
+        this.emit('icon-changed');
+    },
+
     _sync: function() {
         let nItems = this._connectionItems.size;
 
@@ -278,7 +288,7 @@ const NMConnectionSection = new Lang.Class({
             return;
 
         item.connect('icon-changed', Lang.bind(this, function() {
-            this.emit('icon-changed');
+            this._iconChanged();
         }));
         item.connect('activation-failed', Lang.bind(this, function(item, reason) {
             this.emit('activation-failed', reason);
@@ -523,7 +533,7 @@ const NMDeviceModem = new Lang.Class({
         if (this._mobileDevice) {
             this._operatorNameId = this._mobileDevice.connect('notify::operator-name', Lang.bind(this, this._sync));
             this._signalQualityId = this._mobileDevice.connect('notify::signal-quality', Lang.bind(this, function() {
-                this.emit('icon-changed');
+                this._iconChanged();
             }));
         }
     },
@@ -1145,10 +1155,16 @@ const NMDeviceWireless = new Lang.Class({
         this._wirelessHwEnabledChangedId = this._client.connect('notify::wireless-hardware-enabled', Lang.bind(this, this._sync));
         this._activeApChangedId = this._device.connect('notify::active-access-point', Lang.bind(this, this._activeApChanged));
         this._stateChangedId = this._device.connect('state-changed', Lang.bind(this, this._deviceStateChanged));
+        this._notifyConnectivityId = this._client.connect('notify::connectivity', Lang.bind(this, this._iconChanged));
 
         this._sync();
     },
 
+    _iconChanged: function() {
+        this._sync();
+        this.emit('icon-changed');
+    },
+
     destroy: function() {
         if (this._activeApChangedId) {
             GObject.Object.prototype.disconnect.call(this._device, this._activeApChangedId);
@@ -1174,6 +1190,10 @@ const NMDeviceWireless = new Lang.Class({
             this._dialog.destroy();
             this._dialog = null;
         }
+        if (this._notifyConnectivityId) {
+            this._client.disconnect(this._notifyConnectivityId);
+            this._notifyConnectivityId = 0;
+        }
 
         this.item.destroy();
     },
@@ -1211,7 +1231,7 @@ const NMDeviceWireless = new Lang.Class({
     },
 
     _strengthChanged: function() {
-        this.emit('icon-changed');
+        this._iconChanged();
     },
 
     _activeApChanged: function() {